<template>
  <div class="home">
    <!-- 导航栏 -->
    <div class="nav">
      <div class="nav_left">
        <div class="shengfen" :class="{ active: flag }" @click.self="iffn">
          北京市
          <span></span>
        </div>

        <div class="headBox1" v-if="flag">
          <div class="top">
            <p>请选择你所在的收货地区</p>
            <p class="el-icon-close" @click="iffn1"></p>
          </div>
          <div class="title">
            <p>省份</p>
          </div>
          <div class="cent">
            <ul>
              <li v-for="(item, index) in sf" :key="index">
                {{ item }}
              </li>
            </ul>
          </div>
        </div>
      </div>
      <ul class="nav_right">
        <li :class="{ active1: flag1 }" @mouseover="er1" @mouseleave="ve1">
          <span>请登录</span>
          <div class="text"></div>
          <div class="info1" v-if="flag1">
            <p class="title">您好！请登录</p>
            <div class="cent">
              <span v-for="(item, index) in ld" :key="index">{{ item }}</span>
            </div>
          </div>
        </li>
        <li>注册</li>
        <li><span class="el-icon-goods"></span>签到有礼</li>
        <li>我的订单</li>
        <li>
          <el-menu
            class="el-menu-demo"
            mode="horizontal"
            style="height: 30px; background: #f5f5f5"
          >
            <el-submenu index="2" style="height: 30px">
              <template slot="title">我的特卖</template>
              <el-menu-item index="2-1">商品收藏</el-menu-item>
              <el-menu-item index="2-2">品牌收藏</el-menu-item>
              <el-menu-item index="2-3">我的足迹</el-menu-item>
            </el-submenu>
          </el-menu>
        </li>
        <li :class="{ active1: flag2 }" @mouseover="er2" @mouseleave="ve2">
          <span>会员俱乐部</span>
          <div class="info3" v-if="flag2">
            <div class="cent">
              <span>俱乐部首页</span>
            </div>
          </div>
        </li>
        <li :class="{ active1: flag3 }" @mouseover="er3" @mouseleave="ve3">
          <span>客户服务</span>
          <div class="info4" v-if="flag3">
            <div class="cent">
              <span>联系客服</span>
              <span>帮助中心</span>
              <span>服务中心</span>
              <span>知识产权投诉</span>
            </div>
          </div>
        </li>
        <li>手机版</li>
        <li>更多</li>
      </ul>
    </div>
    <!--  -->

    <!-- 头部 -->
    <div class="head">
      <div class="head_left">
        <div class="logo">
          <img src="../../public/image/head-logo.png" alt="" />
        </div>
        <div class="header-vip">
          <img src="../../public/image/head-vip.jpg" alt="" />
        </div>
      </div>

      <div class="head_right">
        <div class="soubox">
          <div class="sou">
            <input type="text" />
            <span></span>
          </div>
          <div class="gouwu">
            <span class="el-icon-goods"></span>
            <p>购物袋</p>
            <div class="sum">0</div>
          </div>
        </div>
        <div class="list">
          <span v-for="(item, index) in headlist" :key="index">
            {{ item }}
          </span>
        </div>
      </div>
    </div>
    <!--  -->

    <!-- 头部侧边栏 -->
    <div class="head-havigation">
      <ul>
        <li @mouseover="aa" @mouseout="aa1">
          <span>商品分类</span>
          <div class="lblList" v-show="show">
            <span
              v-for="(item, index) in lblList"
              :key="index"
              @mouseover="centsj(index)"
              >{{ item }}</span
            >
          </div>
          <div class="havigationCent" v-show="centxbox" @mouseover="yc1" @mouseout="yc">
            <div class="havigationCentChild">
<!-- ------------------------------- -->
              <div v-for="(item, index) in cent" :key="index" class="list">
                <p class="title">{{ item.title }}</p>
                <div class="havigationCentChildlist">
                  <span v-for="(shopItem, index) in item.arrs" :key="index">
                    {{ shopItem}}
                  </span>
                </div>
              </div>
<!--  -->
            </div>
          </div>
        </li>
        <li v-for="(item, index) in headlist1" :key="index">{{ item }}</li>
      </ul>
    </div>
    <!--  -->
  </div>
</template>

<script>
import axios from "axios";
import CeBianCent from "../components/CeBianCent.vue";

export default {
  name: "HomeView",
  data() {
    return {
      flag: false,
      flag1: false,
      flag2: false,
      flag3: false,
      sf: null,
      ld: null,
      headlist: null,
      headlist1: null,
      show: false,
      lblList: null,
      flag4: null,
      centxbox: false,
      cent: null,
    };
  },

  methods: {
    iffn() {
      console.log(111);
      this.flag = true;
    },
    iffn1() {
      console.log(222);
      this.flag = false;
      console.log(this.flag);
    },
    async fndata() {
      let { data } = await axios.get("/api/head");
      this.sf = data.sf;
      this.ld = data.dl;
      this.headlist = data.headlist;
      this.headlist1 = data.headlist1;
      this.lblList = data.lblList;
    },
    er1() {
      this.flag1 = true;
    },
    ve1() {
      this.flag1 = false;
    },
    er2() {
      this.flag2 = true;
    },
    ve2() {
      this.flag2 = false;
    },
    er3() {
      this.flag3 = true;
    },
    ve3() {
      this.flag3 = false;
    },
    aa() {
      this.show = true;
    },
    aa1() {
      this.show = false;
      this.centxbox = false
    },
    async centsj(index) {
      this.centxbox = true;
      let { data } = await axios.get("/api/head");
      this.cent = data.list[index];
    },
    yc(){
      this.centxbox = false
    },
    yc1(){
      this.centxbox = true
    }
  },

  components: {
    CeBianCent,
  },

  created() {
    this.fndata();
  },
};
</script>

<style scoped>
/* 头部侧边栏 */
.head-havigation {
  width: 1170px;
  margin: 0 auto;
}
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
.head-havigation ul {
  display: flex;
}
.head-havigation ul li {
  line-height: 43px;
  padding: 0 15px;
  font-size: 16px;
}
.head-havigation ul li:first-child {
  color: #fff;
  background-color: #f10180;
  text-align: center;
  margin-right: 25px;
  width: 126px;
  position: relative;
}
.head-havigation ul li:nth-child(2) {
  color: #f10180;
  font-weight: 700;
}
.lblList {
  background-color: #f10180;
  position: absolute;
  top: 43px;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  /* height: 359px; */
  z-index: 999;
}
.lblList span {
  height: 45px;
  /* padding-left: 35px; */

  width: 100%;
}
.lblList span:hover {
  background: #fff;
  color: #f10180;
}
.havigationCent {
  width: 1014px;
  height: 492px;
  background: #f5f5f5;
  position: absolute;
  left: 156px;
  z-index: 999;
}
.havigationCentChild {
  width: 769px;
  height: 492px;
  border-top: 1px solid #ccc;
  background: #fff;
  padding: 22px 0 0 40px;
  color: #666666;
}
.havigationCentChild .list {
  display: flex;
  justify-content: space-between;
}
.havigationCentChild .list p.title {
  font-weight: 700;
  font-size: 12px;
  color: #333;
}
.havigationCentChild div.havigationCentChildlist {
  display: flex;
  width: 634px;
}
.havigationCentChild div.havigationCentChildlist span {
  font-size: 12px;
  margin-right: 14px;
}
.havigationCentChild div.havigationCentChildlist span:last-child {
  margin: 0;
}
/*  */

.nav {
  padding: 0 366px;
  margin: 0 auto;
  height: 30px;
  line-height: 27px;
  background-color: #f5f5f5;
  color: #777;
  display: flex;
  justify-content: space-between;
}
.nav_left {
  position: relative;
}
.nav_left .shengfen {
  font-size: 12px;
  color: #333;
  padding: 0 23px 0 15px;
  width: 46px;
  height: 31px;
  position: absolute;
  z-index: 999;
}
.nav_left span {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-block;
  width: 0;
  height: 0;
  border-width: 4px;
  border-color: #999 transparent transparent transparent;
  border-style: solid dashed dotted dashed;
  vertical-align: top;
}
.active {
  background: #fff;
  border: 1px solid #ccc;
  border-bottom: none;
  z-index: 9999;
}
.headBox1 {
  position: absolute;
  z-index: 6;
  top: 30px;
  left: 0;
  padding-right: 15px;
  padding-left: 15px;
  width: 470px;
  background-color: #fff;
  border: 1px solid #ccc;
}
.headBox1 .top {
  padding: 7px 0;
  font-size: 12px;
  color: black;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.headBox1 .title {
  border-bottom: 1px solid #ccc;
  height: 30px;
}
.headBox1 .title p {
  border: 1px solid #ccc;
  width: 68px;
  height: 30px;
  display: inline-block;
  border-top: 2px solid pink;
  font-weight: bold;
  border-bottom: none;
  background: #fff;
  text-align: center;
  font-size: 12px;
  color: #333;
}
.headBox1 .cent {
  padding: 20px 13px 18px;
}
.headBox1 .cent ul {
  display: flex;
  flex-wrap: wrap;
}
.headBox1 .cent ul li {
  padding: 10px;
  width: 36px;
  overflow: hidden;
  height: 22px;
  font-size: 12px;
  color: #333;
}
.nav_right {
  display: flex;
  width: 745px;
  width: 745px;
  justify-content: space-between;
}
.nav_right li {
  font-size: 12px;
  position: relative;
  padding-left: 13px;
  padding-right: 20px;
}
.nav_right li div.text {
  width: 69px;
  height: 2px;
  background: #fff;
  position: absolute;
  top: 29px;
  left: 0;
  z-index: 2;
}
.nav_right li span {
  font-size: 12px;
  color: #777;
}

.nav_right li::after {
  background-image: url(https://shop.vipstatic.com/img/common/header/sprites-hash-06206acd.png?78d4dd66);
  background-position: -207px -184px;
  width: 16px;
  height: 16px;
  position: absolute;
  top: 6px;
  right: -5px;
  z-index: 1;
  content: "";
}

.nav_right li:last-child::after {
  content: "";
  display: none !important;
}
.nav_right li.active1 span {
  color: #f10180;
}
.nav_right li.active1 {
  background: #fff;
  border: 1px solid #ccc;
  border-bottom: none;
}
.nav_right li.active1::after {
  content: "";
  display: none !important;
}
.nav_right li .info1 {
  position: absolute;
  top: 30px;
  padding: 30px 32px 27px 26px;
  border: 1px solid #cdcdcd;
  /* background: #fff; */
  /* z-index: 1; */
  left: 0;
  background: #fff url("../../public/image/nav2.png") no-repeat 21px 31px;
  /* background-position: -164px -142px; */
}
.nav_right li .info1 .title {
  width: 175px;
  margin-left: 42px;
  line-height: 29px;
  border-bottom: #d6d6d6 1px dotted;
  margin-bottom: 22px;
  color: #333;
}
.nav_right li .info1 .cent {
  display: flex;
  padding-right: 41px;
  padding-left: 5px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.nav_right li .info1 .cent span {
  width: 60px;
  color: #333;
}
.nav_right li div.info2 {
  position: absolute;
  width: 390px;
  height: 460px;
  top: 31px;
  border: 1px solid #cdcdcd;
  background: url("../../public/image/3.png") no-repeat;
  left: 50%;
  margin-left: -195px;
}
.nav_right >>> .el-submenu__title {
  padding: 0px;
}
.nav_right >>> .el-menu--horizontal > .el-submenu .el-submenu__title {
  line-height: 32px;
  text-align: center;
  /* padding-right: 16px; */
  /* padding-left: 0px; */
}
.nav_right li .info3 {
  position: absolute;
  left: -1px;
  width: 93px;
  height: 30px;
  background: #fff;
  text-align: center;
  border: 1px solid #cdcdcd;
  border-top: none;
}

.nav_right li .info4 {
  position: absolute;
  left: -1px;
  width: 84px;
  /* height: 30px; */
  background: #fff;
  text-align: center;
  border: 1px solid #cdcdcd;
  border-top: none;
}

.nav_right li .info4 span {
  color: #333;
}
.head {
  width: 1170px;
  margin: 0 auto;
}
.head_left .logo {
  width: 160px;
  height: 100px;
}
.head_left .logo img {
  width: 100%;
  height: 100%;
}
.head_left .header-vip {
  width: 304px;
  height: 100px;
}
.head_left .header-vip img {
  width: 100%;
  height: 100%;
}
.head_left {
  display: flex;
}
.soubox {
  width: 585px;
  display: flex;
  justify-content: space-between;
}
.soubox .sou {
  padding-left: 2px;
  padding-right: 15px;
  background: #fa2a83;
  width: 438px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.soubox .sou input {
  width: 397px;
  height: 32px;
  border: none;
}
.soubox .sou span {
  background-image: url(//shop.vipstatic.com/img/common/header/sprites-hash-06206acd.png?78d4dd66);
  background-position: -285px -104px;
  width: 19px;
  height: 22px;
}
.soubox .gouwu {
  width: 82px;
  height: 32px;
  border: 1px solid #ccc;
  background-color: #f6f7f9;
  display: flex;
  align-items: center;
  padding: 0 5px;
  justify-content: space-between;
}
.soubox .gouwu p {
  color: #333;
  font-size: 12px;
}
.soubox .gouwu .sum {
  width: 24px;
  line-height: 16px;
  color: #fff;
  text-align: center;
  background-color: #f00581;
  border-radius: 8px;
}
.head_right {
  width: 585px;
  margin-top: 33px;
}
.head_right .list span {
  color: #999;
  font-size: 12px;
}
.head_right .list span::after {
  content: "|";
  margin-right: 6px;
  margin-left: 6px;
}
.head_right .list span:last-child::after {
  content: "";
  display: none !important;
}
.head {
  display: flex;
  justify-content: space-between;
}
</style>
